<style type="text/css">
 .bm-jifen
{
  background-image:url("<?php echo Yii::app()->theme->baseUrl; ?>/assets/images/bm-jifen.jpg");
}
.product_img img {
    border:solid 3px #fff;
    margin-right:5px;
}
.product_img img.hover {
    border-color:#ff8800;
}
.product_img img.current {
    border-color:#df0001;
}
</style>
<div class="container bm-page">
  <div class="col-md-8">
    <div class="bm-form-container" >
        <div class="crumbs-box">
            <img alt="" src="<?php echo Yii::app()->theme->baseUrl;?>/assets/images/special/zhuanti_jifen_logo.png">
            <span>积分报名</span>
            <div class="clearfix"></div>
        </div>
                <?php echo $this->renderPartial('_form', array('model' => $model)); ?>
    </div>
  </div>
  <?php include $this->getViewFile('/goodsbm/statement'); ?>
  <div class="clear"></div>
  <?php include $this->getViewFile('/lib/login_and_reg'); ?>
</div>
<?php include $this->getViewFile('/goodsbm/container'); ?>

<script type="text/javascript">

function getInfo() {
    var product_id = $('input[name="RedeemModel[url]"]').val();
    if (product_id == '') {
        return false;
    }
    tips = dialog({
        fixed: true,
        title: '获取商品信息中...'
    }).show();

    $.getJSON('<?php echo YzwController::U('user/bm/iteminfo') ?>', {product_id: product_id}, function(data) {
            tips.close();
            if (data.status) {
                $('#RedeemModel_url').val(data.detail_url);
                $('#RedeemModel_title').val(data.title);
                $('#RedeemModel_product_id').val(data.product_id);
                $('#RedeemModel_worth').val(data.p_price);

                var imgstr = '';
                if (data.images) {
                    $.each(data.images, function(i, v) {
                        if (i == 0) {
                            $('#RedeemModel_thumb').val(v);
                            imgstr += '<img class="current" width="160" height="160" src=' + v + ' />';
                        } else {
                            imgstr += '<img  width="160" height="160"  src=' + v + ' />';
                        }
                    });
                    $('div.thumb').html(imgstr);
                }
            } else {
                if (data.info) {
                    alert(data.info);
                }
            }
        });
}

    
$(function(){

    $(document).on('click', 'div.thumb img', function(){
        $('div.thumb img').removeClass('current');
        $(this).addClass('current');
        $('#RedeemModel_thumb').val(this.src);    
    })

    $('input[name="RedeemModel[url]"]').change(function() {
      getInfo();
    });
    
})

</script>


